package com.alibaba.citrus.cr.sales.plan.facade.service.setting.contract.strategy;

import com.alibaba.citrus.cr.sales.plan.api.setting.contract.trategy.ContractStatStrategy;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author wangyibing
 */
@Component
public class ContractStatStrategyContext {

    @Autowired
    private final Map<String, ContractStatStrategy> contractStatStrategies = new ConcurrentHashMap<>();

    public ContractStatStrategyContext(Map<String, ContractStatStrategy> contractStatStrategyMap, Map<String, ContractStatStrategy> contractStatStrategies) {
        this.contractStatStrategies.clear();
        contractStatStrategyMap.forEach((k, v) -> {
            this.contractStatStrategies.put(k, v);
        });
    }

    public Map<String, ContractStatStrategy> getContractStatStrategies() {
        return contractStatStrategies;
    }

    public ContractStatStrategy getStrategyByDimension(String dimension) {
        return this.contractStatStrategies.get(dimension);
    }
}
